<!--
 * @Descripttion:
 * @Author: Silence
 * @Date: 2023-05-24 08:27:19
 * @LastEditors: Silence
 * @LastEditTime: 2023-05-24 10:56:51
-->
<template>
  <div class="subject">
    <span>{{ n }}</span>
    <span>+</span>
    <span>{{ m }}</span>
    <span>=</span>
    <input type="number" v-model.number="val" />
    <button @click="submit">提交</button>
  </div>
</template>
<script>
export default {
  props: ['id'],
  data () {
    return {
      n: Math.ceil(Math.random() * 9),
      m: Math.ceil(Math.random() * 9),
      val: ''
    }
  },
  created () {
  },
  computed: {
  },
  methods: {
    submit () {
      let statu = '未完成'
      if (this.n + this.m === this.val) {
        statu = '回答正确'
      } else {
        statu = '回答错误'
      }
      this.$Bus.$emit('obj', { id: this.id, statu })
    }
  }
}
</script>
<style lang='less'  scoped>
.subject {
  margin: 5px;
  padding: 5px;
  font-size: 20px;
}
.subject span {
  display: inline-block;
  text-align: center;
  width: 20px;
}
.subject input {
  width: 50px;
  height: 20px;
}
</style>
